package com.css.fxfzdpzs.modules.jcsj.service.impl;

import com.css.fxfzdpzs.modules.jcsj.entity.HistoricalEarthquake;
import com.css.fxfzdpzs.modules.jcsj.repository.JcsjRepository;
import com.css.fxfzdpzs.modules.jcsj.service.JcsjService;
import com.css.fxfzdpzs.modules.jcsj.vo.AreaVo;
import com.css.fxfzdpzs.modules.jcsj.vo.CompanyNumVo;
import com.css.fxfzdpzs.modules.jcsj.vo.EarthquakeNumVo;
import com.css.fxfzdpzs.modules.jcsj.vo.RoadVo;
import com.css.fxfzdpzs.modules.xczh.entity.first.DisasterVisitsCount;
import com.css.fxfzdpzs.modules.xczh.repository.XczhRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class JcsjServiceImpl implements JcsjService {
    @Autowired
    private JcsjRepository jcsjRepository;

    @Override
    public List<AreaVo> getArea(String category) {
        return jcsjRepository.getArea(category);
    }

    @Override
    public List<RoadVo> getLength(String category) {
        return jcsjRepository.getLength(category);
    }

    @Override
    public List<CompanyNumVo> getCompanyNum(String type) {
        return jcsjRepository.getCompanyNum(type);

    }

    @Override
    public List<EarthquakeNumVo> getEarthquakeNum(String category ,String time) {
        if ("0".equals(time)){
            return jcsjRepository.getEarthquakeNum(category);
        }
        Calendar instance = Calendar.getInstance();
        int year = instance.get(Calendar.YEAR);
        return jcsjRepository.getEarthquakeNum1(category,year+"");
    }

    @Override
    public List<HistoricalEarthquake> getEarthquakeData() {
        return jcsjRepository.getEarthquakeData();
    }
}
